-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sort header display names and avatars in a group chat view #28991
Conversation
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
* | ||
* @returns {Boolean} | ||
*/ | ||
const isGroupChat = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem ideal to me, i am going to check if there is a better way
This would mean we have to update this condition every time there might be a new chat report type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realise chatType
was available here too. Makes sense to use it.
I was initially wary of using participantAccountIDs.length > 2
because I thought it was possible to create a group chat with just 2 participants but discovered I was wrong after testing. This is perfect, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akinwale I think we might be changing a lot about Group chats soon so this might change and yes then you can have a group chat with only one member. But that is not the case now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still had to make use of the !optionItem.isMoneyRequestReport
and !optionItem.isExpenseRequest
checks in there as some tests fail without them.
Rechecking.
EDIT: False alert. They were failing because the tests were expecting 2 participants to be in sorted order, which is not the case anymore since it's only considered a group chat if there are 3 or more participants.
@akinwale Conflicts! |
@allroundexperts This is ready for review. Thanks! |
@allroundexperts bump |
@akinwale Will get to this tomorrow. |
@allroundexperts Have you had a chance to look at this yet? Hoping to get this closed soon. Thanks. |
return optionItem.type === CONST.REPORT.TYPE.CHAT && _.isEmpty(optionItem.chatType) && !optionItem.isThread && lodashGet(optionItem, 'displayNamesWithTooltips.length', 0) > 2; | ||
}; | ||
|
||
const fullTitle = isGroupChat() ? ReportUtils.getDisplayNamesStringFromTooltips(optionItem.displayNamesWithTooltips) : optionItem.text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of making isGroupChat
a function @akinwale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just to make things clearer and more readable. There are 4 conditions being checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I get that, but can't you just save it in a variable instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ie
const isGroupChat = optionItem.type === CONST.REPORT.TYPE.CHAT && _.isEmpty(optionItem.chatType) && !optionItem.isThread && lodashGet(optionItem, 'displayNamesWithTooltips.length', 0) > 2;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I suppose that works too! 😅
Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@akinwale Conflicts now! |
@allroundexperts Fixed. |
Reviewer Checklist
Screenshots/Videos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing well!
All yours @stitesExpensify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left a couple of questions
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.90-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.90-2 🚀
|
🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.91-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.91-8 🚀
|
Details
Follow-up to #28218. This adds additional checks to ensure that the sorted display names are displayed as a title ONLY for group chats.
A new method was added to the
ReportUtils
file,isGroupChat
. The following conditions are taken into consideration to determine whether or not a report is a group chat.Fixed Issues
$ #28048
PROPOSAL: #28048 (comment)
Tests
Offline tests
N/A
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
28048-web.mp4
Mobile Web - Chrome
Mobile Web - Safari
Desktop
28048-desktop.mp4
iOS
Android